package com.hs.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.Appointment;
import com.hs.sfzy.entity.Article;
import com.hs.sfzy.entity.Charge;
import com.hs.sfzy.entity.Consult;
import com.hs.sfzy.mapper.ChargeMapper;
import com.hs.sfzy.mapper.UserMarkMapper;
import com.hs.sfzy.service.ChargeService;
import com.hs.sfzy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @ClassName ChargeServiceImpl
 * @Description TODO
 * @Author liubo
 * @Date 2024年10月21日 10:45
 * @Version 1.0
 */
@Service
public class ChargeServiceImpl implements ChargeService {
    @Autowired
    private ChargeMapper chargeMapper;

    @Override
    public int insert(Charge charge) {

        return chargeMapper.insert(charge);
    }

    @Override
    public int delete(int id) {
        List<Charge> select = chargeMapper.selectAll(new Charge());
        if (select.size()>0){
            return Result.error("删除失败").getStatus();
        }
        return chargeMapper.delete(id);
    }

    @Override
    public int update(Charge charge) {

        return chargeMapper.update(charge);
    }

    @Override
    public List<Charge> selectAll(Charge charge) {

        return chargeMapper.selectAll(charge);
    }

    @Override
    public Charge selectById(int id) {

        return chargeMapper.selectById(id);
    }

    @Override
    public PageInfo<Charge> selectByPageInfo(int pageNum, int pageSize, Charge charge) {

        PageHelper.startPage(pageNum,pageSize);
        List<Charge> list=chargeMapper.selectAll(charge);
        PageInfo<Charge> pageInfo=new PageInfo<Charge>(list);
        return pageInfo;
    }
}
